package com.only4play.system.web.question;

import com.only4play.common.model.JsonObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-04-07
 */
@RestController
@RequestMapping(value = "question")
@Schema(title = "问卷调查")
@RequiredArgsConstructor
public class QuestionController {

  private final QuestionFeignService questionFeignService;

  /**
   * createRequest
   */
  @PostMapping("createQuestion")
  public JsonObject<Long> createQuestion(@RequestBody QuestionCreateRequest request) {
    return questionFeignService.createQuestion(request);
  }

  /**
   * update request
   */
  @PostMapping("updateQuestion")
  public JsonObject<String> updateQuestion(@RequestBody QuestionUpdateRequest request) {
    return questionFeignService.updateQuestion(request);
  }

  /**
   * valid
   */
  @PostMapping("valid/{id}")
  public JsonObject<String> validQuestion(@PathVariable Long id) {
    return questionFeignService.validQuestion(id);
  }

  /**
   * invalid
   */
  @PostMapping("invalid/{id}")
  public JsonObject<String> invalidQuestion(@PathVariable Long id) {
    return questionFeignService.invalidQuestion(id);
  }

  /**
   * findById
   */
  @GetMapping("findById/{id}")
  public JsonObject<QuestionResponse> findById(@PathVariable Long id) {
    return questionFeignService.findById(id);
  }

  /**
   * findByPage request
   */
  @PostMapping("findByPage")
  public JsonObject<PageResult<QuestionResponse>> findByPage(
      @RequestBody PageRequestWrapper<QuestionQueryRequest> request) {
    return questionFeignService.findByPage(request);
  }

}
